package Impl;

/**
 * Created with IntelliJ IDEA.
 * User: Julien
 * Date: 18/03/14
 * Time: 10:19
 * To change this template use File | Settings | File Templates.
 */
public class Objet implements Comparable {
    private static int nbid=1;
    private int id;
    private float poids;
    private float util;

    public Objet() {
    }

    public Objet(float poids, float util) {
        id = nbid;
        this.poids = poids;
        this.util = util;
        nbid++;
    }

    public float getpoidss() {
        return poids;
    }

    public float getUtil() {
        return util;
    }

    public float getRapportPU() {
        return (util / poids);
    }

    @Override
    public int compareTo(Object o) {
        Objet objet = (Objet) o;
        if (getRapportPU() > objet.getRapportPU()) {
            return -1;
        } else if (getRapportPU() == objet.getRapportPU()) {
            return 0;
        }
        return 1;
    }

    @Override
    public String toString() {
        return "Objet{" +
                "id=" + id +
                '}';
    }
}
